// 将时间戳转为时间字符串模板
const timeFormatTimestamp2String = (timestamp) => {
  const date = new Date(timestamp);
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let strDate = date.getDate();

  let h = date.getHours();
  h = h < 10 ? "0" + h : h;

  let min = date.getMinutes();
  min = min < 10 ? "0" + min : min;

  if (month >= 1 && month <= 9) {
    month = "0" + month;
  }
  if (strDate >= 0 && strDate <= 9) {
    strDate = "0" + strDate;
  }
  return year + "-" + month + "-" + strDate + " " + h + ":" + min;
};

module.exports = { timeFormatTimestamp2String };
